package com.specter.mvc.model.service.impl;

import java.io.Serializable;
import java.util.List;

import com.specter.mvc.model.Page;
import com.specter.mvc.model.Request;
import com.specter.mvc.model.dao.BaseDao;
import com.specter.mvc.model.service.BaseService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Note:基本服务类接口
 * 
 * @author Liang.Wang
 * @version 2010-11-23 下午03:00:43
 */
@Service
public class BaseServiceImpl implements BaseService {

	@Autowired
	private BaseDao baseDao;

	@Override
	public <T> boolean insert(T entity) {
		return this.baseDao.insert(entity);
	}

	@Override
	public <T> boolean insertBatch(List<T> entities) {
		return this.baseDao.insertBatch(entities);
	}

	@Override
	public <T> boolean insertOrUpdate(T entity) {
		return this.baseDao.insertOrUpdate(entity);
	}

	@Override
	public <T> boolean insertOrUpdate(List<T> entities) {
		return this.baseDao.insertOrUpdate(entities);
	}

	@Override
	public <T> boolean delete(T entity) {
		return this.baseDao.delete(entity);
	}

	@Override
	public boolean deleteById(Class<?> clazz, Serializable id) {
		return this.baseDao.deleteById(clazz, id);
	}

	@Override
	public boolean deleteByIds(Class<?> clazz, List<? extends Serializable> ids) {
		return this.baseDao.deleteById(clazz, ids);
	}

	@Override
	public <T> boolean updateById(T entity, boolean isBlank) {
		return this.baseDao.update(entity, true);
	}

	@Override
	public <T> boolean updateById(List<T> entities, boolean isBlank) {
		return this.baseDao.update(entities, true);
	}

	@Override
	public <T> T selectOne(T entity) {
		return this.baseDao.selectOne(entity);
	}

	@Override
	public <T> T selectOne(Class<T> clazz, Serializable id) {
		return this.baseDao.selectOneById(clazz, id);
	}

	public <T> List<T> select(T entity, Object orders) {
		return this.baseDao.select(entity, orders);
	}

	@Override
	public <T> List<T> select(Class<T> clazz, Object params, Object orders) {
		return this.baseDao.select(clazz, params);
	}

	@Override
	public <T> List<T> selectByIds(Class<T> clazz, List<? extends Serializable> ids, Object orders) {
		return this.baseDao.selectById(clazz, ids, orders);
	}

	@Override
	public <T> Page<T> selectPage(Class<T> clazz, Request request) {
		return this.baseDao.selectPage(clazz, request);
	}

}
